<%@ Page Language="VB" MasterPageFile="~/MasterPageExpandable.master" AutoEventWireup="false" CodeFile="AdHocFinancial.aspx.vb" Inherits="AdHocReport_AdHocFinancial" title="Ad Hoc Financial History" %>

<%@ Register Src="AdHocMenu.ascx" TagName="AdHocMenu" TagPrefix="uc1" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script language="javascript" type="text/javascript">
  function toggleText(spanObject)
  {
     if (spanObject.innerHTML=='click to hide')
         spanObject.innerHTML='click to show';
     else
         spanObject.innerHTML='click to hide';
  }

  function setOperandList(operandId, fieldDropDownId) 
  {
    var ddlOperator=document.getElementById(operandId);  //refers to the operand dropdownlist 
    var ddlEditFields=document.getElementById(fieldDropDownId);
    var fieldName=ddlEditFields.options[ddlEditFields.selectedIndex].value;
    var fieldType=GetFieldType(fieldName);  
    var selectedValue;

   switch(fieldType)
    {
        case 'varchar':
            selectedValue='1';
            break;
        case 'int':
        case 'float':
        case 'datetime':
           selectedValue='2';
           break;
        case 'bit':
           selectedValue='3';
           break;
        default:
           selectedValue='4';
    }  
    
    setOptions(ddlOperator, selectedValue);
           
   }   
  
  function validateTextEntered(fieldNameId, textBoxId)
  {
     var ddlFieldName=document.getElementById(fieldNameId);
     var selectedFieldName=ddlFieldName.options[ddlFieldName.selectedIndex].text;
     var selectedFieldValue=document.getElementById(textBoxId).value;
  
     if(selectedFieldName=='Transaction Date')
        {
            if (isNaN(Date.parse(selectedFieldValue)))
                alert('Please enter a valid date for Transaction Date.');
        }
     if (selectedFieldName=='Id Number')
      {
         if (isNaN(parseFloat(selectedFieldValue)))
                 alert('Id should be numeric');     
      }    
  }
  
  function setOptions(ddl, menuType)
  {
    if (menuType=='1')
     {
        SetOption(ddl, 0, 1, 'Equals');
        SetOption(ddl, 1, 1, 'Starts With');        
        SetOption(ddl, 2, 1, 'Contains');
        ddl.disabled=false;
     }
     
     if (menuType=='2')
     {
       SetOption(ddl, 0, 2, 'Equals');
        SetOption(ddl, 1, 2, 'Less Than');
        SetOption(ddl, 2, 2, 'Greater Than');
        ddl.disabled=false;
     }
     
     if (menuType=='3')
     {
       SetOption(ddl, 0, 3, 'Equals');
       ddl.selectedIndex=0;
       ddl.disabled=true;
     }   
     
     if (menuType=='4')
     {
       SetOption(ddl, 0, 4, 'Starts With');
        SetOption(ddl, 1, 4, 'Equals');
        SetOption(ddl, 2, 4, 'Contains');
        SetOption(ddl, 3, 4, 'Less Than');
        SetOption(ddl, 4, 4, 'Greater Than');
       ddl.selectedIndex=0;
       ddl.disabled=false;
     }   
     
  }
  
  function SetOption(ddl, idx, val, txt)
  {
   // ddl.options[idx].value=val;
    ddl.options[idx].text=txt;
  }
  
  
  function populateOptions(ddl, menuType)
  {
     
     var numberOfOptions = ddl.options.length;   
     for (i=0; i<numberOfOptions; i++)   
         ddl.remove(0);   
         
     if (menuType=='1')
     {
       AddOption(ddl, 1, 'Starts With');
        AddOption(ddl, 1, 'Equals');
        AddOption(ddl, 1, 'Contains');
     }
     
     if (menuType=='2')
     {
       AddOption(ddl, 2, 'Equals');
        AddOption(ddl, 2, 'Less Than');
        AddOption(ddl, 2, 'Greater Than');
     }
     
     if (menuType=='3')
     {
       AddOption(ddl, 3, 'Equals');
     }    
     
     if (menuType=='4')
     {
        AddOption(ddl, 4, 'Starts With');
        AddOption(ddl, 4, 'Equals');
        AddOption(ddl, 4, 'Contains');    
        AddOption(ddl, 4, 'Less Than');
        AddOption(ddl, 4, 'Greater Than');    
     }
         
  }  
  
  function AddOption(ddl, val, txt)
  {
     var opt = document.createElement("option");
     opt.text = txt;
     opt.value = val;
     ddl.options.add(opt); 

  }
  
  function GrayOutCheckBoxList()
  {
  
  if (document.getElementById("CheckBoxListDiv").disabled)
    document.getElementById("CheckBoxListDiv").disabled=false;
  else
    document.getElementById("CheckBoxListDiv").disabled=true;
  }
  
</script>

<asp:Literal ID="javascriptLiteral" runat="server"></asp:Literal>

    <uc1:AdHocMenu ID="AdHocMenu1" runat="server" />
    
    <cc1:Accordion ID="Accordion1" runat="server" HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected"
            ContentCssClass="accordionContent" FadeTransitions="false" FramesPerSecond="40" 
            TransitionDuration="250" AutoSize="None" RequireOpenedPane="false" SuppressHeaderPostbacks="true">
    <Panes>
    <cc1:AccordionPane ID="SearchCriteriaPane" runat="server">
    <Header><table width="100%"><tr><td align="left">Search Criteria</td><td align="right"><span id="accordionSpan1" style="font-size:x-small;">click to hide/show</span></td></tr></table></Header>
    <Content>
    <asp:UpdatePanel ID="GridViewUpdatePanel" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
<table><tr valign="top"><td>
<table>
   <tr><td colspan="4"><asp:Label Id="SearchCriteriaLabel" runat="server" Text="Search Criteria" CssClass="labelNoWidthOrMargin"></asp:Label>
   </td></tr>
   <tr><td>
  
       <asp:GridView ID="SearchCriteriaGridView" runat="server" SkinID="Report" EmptyDataText="No Criteria Selected." EmptyDataRowStyle-HorizontalAlign="Center" ShowHeader="false" ShowFooter="false" GridLines="None" BorderStyle="None" AutoGenerateColumns="false" CssClass="labelNoWidthOrMargin">
       <Columns>
       <asp:TemplateField ItemStyle-Width="40px">
         <ItemTemplate>
            <asp:Label ID="AndOrLabel" runat="server" CssClass="labelNoWidthOrMargin"></asp:Label>
         </ItemTemplate>
       </asp:TemplateField>
       <asp:TemplateField>
        <ItemTemplate>
                <asp:DropDownList ID="EditFieldNameDropDown" runat="server"></asp:DropDownList>
           </ItemTemplate>
           <FooterTemplate>
           </FooterTemplate>
       </asp:TemplateField>
       <asp:TemplateField>
           <ItemTemplate>              
                <asp:DropDownList ID="EditOperatorDropDown" runat="server">
                    <asp:ListItem Text="Starts With"></asp:ListItem>
                    <asp:ListItem Text="Equals"></asp:ListItem>
                    <asp:ListItem Text="Contains"></asp:ListItem>
           </asp:DropDownList>
           </ItemTemplate>
       </asp:TemplateField>
       <asp:TemplateField>
         <ItemTemplate>
              <asp:TextBox ID="EditValueTextBox" runat="server" Text=""></asp:TextBox>
         </ItemTemplate>
       </asp:TemplateField>
       <asp:TemplateField>
          <ItemTemplate>
            <asp:Button ID="RemoveButton" Text="Remove" runat="server" CommandName="Delete" CommandArgument='<%#Eval("Id")%>'  />
          </ItemTemplate>
       </asp:TemplateField>
       </Columns>       
       </asp:GridView>      
     </td></tr>
   </table>       
   <table cellpadding="5">
     <tr style="background-color: White; height:1px;"><td colspan="5"></td></tr>
     <tr><td colspan="5"><asp:Label ID="AddLabel" runat="server" Text="Add Criterion" CssClass="labelNoWidthOrMargin"></asp:Label></td></tr>
     <tr>
     <td style="width:40px;"></td>
     <td><asp:DropDownList ID="AddFieldNameDropDown" runat="server"> 
           </asp:DropDownList></td>
           <td><asp:DropDownList ID="AddOperatorDropDown" runat="server">
                    <asp:ListItem Text="Starts With"></asp:ListItem>
                    <asp:ListItem Text="Equals"></asp:ListItem>
                    <asp:ListItem Text="Contains"></asp:ListItem>
           </asp:DropDownList></td>
           <td><asp:TextBox ID="AddValueTextBox" runat="server" Text=""></asp:TextBox></td>
           <td> <asp:Button ID="AddButton" Text="Add" runat="server"  /></td>
           </tr>
           </table>
 </td>
 <td width="5px"></td>
 <td>
   <table style="border-color:White;border: 1px solid;"> 
   <tr><td colspan="5"><asp:Label ID="OptionsLabel" runat="server" Text="Options" CssClass="labelNoWidthOrMargin" Font-Bold="true"></asp:Label></td></tr>
   <tr><td></td><td colspan="2"><asp:Label ID="LoadReportLabel" runat="server" Text="Load saved report:" CssClass="labelNoWidthOrMargin"></asp:Label>
   <asp:DropDownList ID="SavedReportsDDL" runat="server"></asp:DropDownList></td>
   <td align="right"><asp:Button ID="LoadReportButton" runat="server" Text="Load Report" /></td></tr>
<tr><td></td><td><asp:Label ID="QueryTypeLabel" runat="server" Text="Query Type" CssClass="labelNoWidthOrMargin"></asp:Label></td>
  <td></td><td><asp:Label ID="SortOrderLabel" runat="server" Text="SortOrder" CssClass="labelNoWidthOrMargin"></asp:Label></td>
</tr>
<tr><td></td><td>
<asp:RadioButtonList ID="ExportTypeRadioButtonList" runat="server" RepeatDirection="Vertical" CssClass="labelNoAlign">
    <asp:ListItem Text="Complete" Value="Complete" Selected="True"></asp:ListItem>
    <asp:ListItem Text="Distinct" Value="Distinct"></asp:ListItem>
  </asp:RadioButtonList>

</td>
<td width="30px"></td>
<td>
     <asp:DropDownList ID="SortOrder" runat="server"></asp:DropDownList>
</td></tr>
</table>
</td></tr>
<tr><td colspan="2" align="center"><asp:Label ID="WarningLabel" runat="server" ForeColor="Red" Text="Please Add at least one search criterion." Visible="false" CssClass="labelNoWidthOrMargin"></asp:Label>
</td></tr>
</table>
</ContentTemplate>
        <Triggers>
       <asp:AsyncPostBackTrigger ControlID="AddButton" EventName="Click" />
       </Triggers>
       </asp:UpdatePanel>
       
    <table></table>
    
    </Content>
    </cc1:AccordionPane>
    <cc1:AccordionPane ID="FieldListPane" runat="server">
    <Header><table width="100%"><tr><td align="left">Output Fields</td><td align="right"><span id="Span1" style="font-size:x-small;">click to hide/show</span></td></tr></table></Header>
<Content>
<table>
<tr><td colspan="5" align="center"><h2><asp:Label ID="ColumnsLabel" runat="server" Text="Select Columns to Display" CssClass="labelNoWidthOrMargin"></asp:Label></h2></td></tr>
     <tr><td><asp:Label ID="Label1" runat="server" Text="Select which columns to include in your results, then click Save.  If nothing is selected, then all columns will be displayed." CssClass="labelNoAlign"></asp:Label></td></tr>
     <tr><td>
     <div id="CheckboxListDiv"><asp:CheckBoxList ID="ColumnsCheckBoxList" runat="server" RepeatColumns="3" CellPadding="5" CellSpacing="5" CssClass="labelCheckboxNoWidth" BackColor="Transparent" DataTextField="ColumnName" DataValueField="ColumnId"></asp:CheckBoxList></div>
     </td></tr>
     <tr><td><asp:CheckBox ID="DisplayAllCheckBox" runat="server" Text="Display All Columns" CssClass="labelCheckboxNoWidth" /></td></tr>
     <tr><td style="width:900px; text-align:center;"><asp:Button ID="SearchButton" runat="server" Text="Search" /></td></tr>
</table>
</Content>
    </cc1:AccordionPane>
    <cc1:AccordionPane ID="SearchResultsPane" runat="server">
   <Header>
  <table width="100%"><tr><td align="left">Search Results</td><td align="right"><span id="accordionSpan2" style="font-size:x-small;">click to hide/show</span></td></tr></table>
  </Header>
  <Content>
   <table align="center">
   <tr><td colspan="3" align="center">
   <asp:GridView ID="SearchResultsGridView" runat="server" CssClass="gridOffsetSmall" Font-Names="Verdana" Font-Size="Small" HorizontalAlign="Center" AllowPaging="true" AllowSorting="true"  Visible="true" AutoGenerateColumns="false"
   CellPadding="5" BorderColor="#21334B" BorderStyle="Solid" GridLines="Vertical">
   <Columns>
   </Columns>
   </asp:GridView></td></tr>
   <tr><td colspan="2"><asp:Label ID="ResultsCountLabel" CssClass="labelNoWidthOrMargin" runat="server"></asp:Label></td><td><asp:Label ID="PageSizeLabel" runat="server" Text="Page Size"  CssClass="labelNoWidthOrMargin"></asp:Label>
   <asp:DropDownList ID="PageSizeDropDown" runat="server" AutoPostBack="true">
      <asp:ListItem Text="10" Value="10"></asp:ListItem>
      <asp:ListItem Text="20" Value="20"></asp:ListItem>
      <asp:ListItem Text="30" Value="30"></asp:ListItem>
      <asp:ListItem Text="40" Value="40"></asp:ListItem>
      <asp:ListItem Text="50" Value="50"></asp:ListItem>
      <asp:ListItem Text="60" Value="60"></asp:ListItem>
      <asp:ListItem Text="70" Value="70"></asp:ListItem>
      <asp:ListItem Text="80" Value="80"></asp:ListItem>
      <asp:ListItem Text="90" Value="90"></asp:ListItem>
      <asp:ListItem Text="100" Value="100"></asp:ListItem>
      <asp:ListItem Text="200" Value="200"></asp:ListItem>
      <asp:ListItem Text="500" Value="500"></asp:ListItem>
   </asp:DropDownList></td></tr>
   <tr><td style="width:200px; text-align:left;">
   </td>
   <td style="width:450px; text-align:center;">
   
   <asp:Panel ID="ExportingPanel" runat="server" Visible="false">
   <table><tr><td>
   <asp:Label ID="ExportingLabel" runat="server" Text="Exporting..."></asp:Label>
   </td></tr>
   </table>
   </asp:Panel>
   
   <asp:Button ID="ExportButton" runat="server" Text="Export" />
   </td>
   <td><asp:Button ID="SaveReportButton" runat="server" Text="Save Report" /></td>
   </tr>
   </table>
   
     <asp:Panel ID="SaveReportPanel" runat="server" Style="display:none;"  CssClass="modalPopup">
     <table style="border-width:1px; border-color:Black; border-style:solid;">
     <tr><td><h2><asp:Label ID="SaveReportHeader" runat="server" Text="Save Report" CssClass="labelNoWidthOrMargin"></asp:Label></h2></td></tr>
     <tr><td><asp:Label ID="SaveReportLabel" runat="server" Text="Enter Report Name:" CssClass="labelNoAlign"></asp:Label>
     <asp:TextBox ID="ReportName" runat="server"></asp:TextBox>
     </td></tr>
     <tr><td align="center"><asp:Button ID="SaveButton" runat="server" Text="Save Report" /><asp:Button Id="CancelSaveButton" runat="server" Text="Cancel" /></td></tr>
     </table>
   </asp:Panel>
   
   <cc1:ModalPopupExtender ID="SaveReportModalPopup" runat="server" 
     TargetControlID="SaveReportButton"
     PopupControlID="SaveReportPanel"
     CancelControlID="CancelSaveButton"
     DropShadow="true" BackgroundCssClass="modalBackground"></cc1:ModalPopupExtender>
  
</Content>
  
</cc1:AccordionPane>
    </Panes>
    </cc1:Accordion>
    <br />
    
    <asp:Label ID="ErrorLabel" runat="server" ForeColor="Red" Visible="false" Text=""></asp:Label>
    
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
</asp:Content>

